<?php
namespace Mobile\Controller;
use Think\Controller;
use Qywx\Controller\BaseController;
class IndexController extends CommunalController{
	//首页 designed by:zhangsen 2017-04-24
	function index(){
        $this->display();
	}
	
	//登录-->判断
	function do_login(){
		parent::do_login();
	}

	//登录 designed by:zhangsen 2017-04-24
	function login(){
	    $QyWx = new BaseController();
	    $isQyWx = $QyWx->isQyWx();
	    if ($isQyWx == true){
            $action = '/Mobile/Index/back';
	        $QyWx->index($action);die;
        }
	    $this->assign('login_type',$_REQUEST['login_type']);
		if(cookie('username')){
			$this->assign('username',cookie('username'));
		}
		$this->display('Index/login');
	}

    public function back()
    {
        $QyWx = new BaseController();
        $userInfo = $QyWx->back();
        if ($userInfo['errcode'] == 0) {
            $name = $userInfo['name'];
            $user_ck = M("db_user")->where("username='$name'")->find();
            if ($user_ck) {
                //授权成功！
                $_SESSION['uid'] = $user_ck['id'];
                $_SESSION['username'] = $user_ck['username'];
                $user = $this->get_user($_SESSION['uid']);
                $_SESSION['permissions_rule'] = $user['permissions_rule'];
                $_SESSION['select_id'] = explode(',', $user['select_id']);
                $_SESSION['manage_id'] = explode(',', $user['manage_id']);
                $_SESSION['sw_select_id'] = explode(',', $user['sw_select_id']);
                $_SESSION['sw_manage_id'] = explode(',', $user['sw_manage_id']);
                $_SESSION['department'] = $this->get_department($user['department_id']);
                $_SESSION['department_id'] = $user['department_id'];
                $_SESSION['permissions_id'] = $user['permissions_id'];
                $_SESSION['center_id'] = $user['center_id'];
                $_SESSION['center_type'] = $this - $this->get_oa_dep_name($user['center_id']);
                $this->redirect('/Mobile/Index/index');
            } else {
                $this->error('暂未匹配到登录人信息，请联系EHR人员');
            }
        } else {
            $this->error('授权失败');
        }
    }

    //退出 designed by:zhangsen 2017-08-09
	function login_out(){
		cookie('openid',null);
		session_destroy();
		$this->redirect('/Mobile/Index/login');
	}
	
	//日程管理
	function schedule_list(){
		//str_replace(array('/'),'-',$date_str)
		//默认当前日期前7天详情
		//$ldate=$_REQUEST['date'];
		if(!empty($_REQUEST['data'])){$ldate=$_REQUEST['date'];}else{$ldate=date("Y-m-d");}
		$db_schedule=M('db_schedule');
		$db_schedule_detail=M('db_schedule_detail');
		$ldates=date('Y-m-d',strtotime("$ldate - 7 day"));
		$where_l['date']=array('between',array($ldates,$ldate));
		$where_l['add_uid']=$this->login_id;
		$data=$db_schedule->field('db_schedule.*')->where($where_l)->join('left join db_schedule_detail on db_schedule.id=db_schedule_detail.mid')->group('db_schedule.id')->order('date desc')->select();
		foreach($data as $key=>$value){
			//工作类型
			$work_type_name=$this->get_db_universal_type(13,1,NULL,NULL,$value['work_type']);
			$data[$key]['work_name']=$work_type_name['name2'];
			//填报类型
			$type_name=$this->get_db_universal_type(11,1,NULL,NULL,$value['type']);
			$data[$key]['type_name']=$type_name['name2'];
			//
			$fill_post_name=$this->get_db_universal_type(12,1,NULL,NULL,$value['fill_post']);
			$data[$key]['fill_post_name']=$fill_post_name['name2'];
			//休息人员
			$userd=$this->get_user($value['agent']);
			$data[$key]['agent_name']=$userd['username'];
			$data[$key]['position']=$userd['position_descr'];
			$data[$key]['mobilephone']=$userd['mobilephone'];
			//日期
			$where_det['mid']=$value['id'];
			$where_det['date']=array('between',array($ldates,$ldate));
			$detail=$db_schedule_detail->where($where_det)->order('date')->select();
			foreach($detail as $kk=>$vv){
				if($kk==0){
					$data[$key]['show_date']=$vv['date'];
				}
				if(count($detail)!=1){
					if($kk+1==count($detail)){
					$data[$key]['show_date'].=' ~ '.$vv['date'];
					}
				}
				$second1=strtotime($vv['date']);
				$second2=strtotime(date('Y-m-d'));
				if(($second1-$second2)/86400>7){
					$data[$key]['noedit']=1;
				}
				if(($second2-$second1)/86400>7){
					$data[$key]['noedit']=1;
				}
			}
			//项目
			$pd=$this->get_project($value['pid']);
			$data[$key]['project_num']=$pd['project_num'];
			$data[$key]['project_name']=$pd['project_name'];
			//休息审核
			$db_audit_main=M('db_audit_main');
			$where_m['audit_id']=$value['id'];
			$where_m['type']=4;
			$audit=$db_audit_main->where($where_m)->find();
			$data[$key]['order_number']=$audit['order_number'];
			$data[$key]['audit_type']=$audit['audit_type'];
			$data[$key]['status']=$audit['status'];
			$data[$key]['dh_date']=$audit['dh_date'];
			$data[$key]['dh_message']=$audit['dh_message'];
			$data[$key]['arrive_status']=$audit['arrive_status'];
			$data[$key]['submit_info']=$audit['submit_info'];
			$data[$key]['dh_user']=$this->get_username($audit['dh_uid']);
			if($audit['status']>1){$data[$key]['noedit']=1;}
			$data[$key]['audit_id']=$audit['id'];
		}
		$this->assign('data',$data);
		$this->display();
	}
	
	//日程管理列表-->添加弹框 designed by:zhaoshihao 2017-12-05
	function schedule_list_add(){
		//如果有id查询详情
		$db_schedule=M('db_schedule');
		$where['id']=$_REQUEST['id'];
		$data=$db_schedule->where($where)->find();
		if(!empty($data)){
			$db_schedule_detail=M('db_schedule_detail');
			$where_d['mid']=$_REQUEST['id'];
			$detail=$db_schedule_detail->where($where_d)->order('date')->select();
			foreach($detail as $key=>$val){
				$second1=strtotime($val['date']);
				$second2=strtotime(date('Y-m-d'));
				if(($second1-$second2)/86400>7){
					$data['noedit']=1;
				}
				if(($second2-$second1)/86400>7){
					$data['noedit']=1;
				}
				if($key==0){
					$show_date=$val['date'];
				}
				if(count($detail)!=1){
					if($key+1==count($detail)){
						$show_date2=$val['date'];
					}
				}
			}
			//项目
			$pd=$this->get_project($data['pid']);
			$data['project_num']=$pd['project_num'];
			$data['project_name']=$pd['project_name'];
			//休息选择项目人员
			$pj=$this->get_project($data['pid']);
			$project_bg=$this->get_project_bg($data['pid']);
			//姓名下拉菜单
			if($project_bg['status']==1){
				$use=array();
				$use[]=$pj['manager_uid'];
				$use[]=$pj['director_uid'];
				$db_project_user=M('db_project_user');
				$where_u['pid']=$data['pid'];
				if(!empty($show_date2)){
					$where_u['_string']="(('".$show_date."'<=come_date and '".$show_date2."'>`out_date`) or ('".$show_date."'<=come_date and out_date is NULL))";
				}else{
					$where_u['_string']="(('".$show_date."'>=come_date and '".$show_date."'<`out_date`) or ('".$show_date."'>=come_date and out_date is NULL))";
				}
				$result=$db_project_user->where($where_u)->order('come_date desc')->group('uid')->select();
				foreach($result as $key=>$value){
					if($value['uid']!=$this->login_id){
						$use[]=$value['uid'];
					}
				}
				$use=array_flip(array_flip($use));
				$uses=join(',',$use);
				$users=$this->get_all_username(1,NULL,NULL,NULL,$uses);
				foreach($users as $key=>$value){
					$user=$this->get_user($value['id']);
					$users[$key]['position']=$user['position_descr'];
					$users[$key]['mobilephone']=$user['mobilephone'];
				}
			}
			$this->assign('users',$users);
			//工作类型
			$work_type_name=$this->get_db_universal_type(13,1,NULL,NULL,$data['work_type']);
			if(!empty($data)){
				$data['work_type_name']=$work_type_name['name3'];
				$data['work_name']=$work_type_name['name2'];
				$userd=$this->get_user($data['agent']);
				$data['agent_name']=$userd['username'];
				$data['position']=$userd['position_descr'];
				$data['mobilephone']=$userd['mobilephone'];
			}
			//休息审核
			$db_audit_main=M('db_audit_main');
			$where_m['audit_id']=$_REQUEST['id'];
			$where_m['type']=4;
			$audit=$db_audit_main->where($where_m)->find();
			$data['order_number']=$audit['order_number'];
			$data['audit_type']=$audit['audit_type'];
			$data['status']=$audit['status'];
			$data['audit_id']=$audit['id'];
			$data['dh_date']=$audit['dh_date'];
			$data['dh_message']=$audit['dh_message'];
			$data['arrive_status']=$audit['arrive_status'];
			$data['submit_info']=$audit['submit_info'];
			$data['dh_user']=$this->get_username($audit['dh_uid']);
			$this->assign('data',$data);
			$this->assign('end',$show_date2);
			$this->assign('start',$show_date);
			$this->assign('type',$data['type']);
		}else{
			//传值
			$this->assign('start',$_REQUEST['start']);
			$this->assign('end',$_REQUEST['end']);
			$this->assign('type',$_REQUEST['type']);
		}
		//项目
		//填报项目筛选
		//所有项目
		$project=array();
		$db_project_user=M('db_project_user');
		$db_project=M('db_project');
		
		$where_p['_string']="(manager_uid=".$this->login_id.") or (director_uid=".$this->login_id.")";
		$where_p['status']=1;
		$where_p['center_id']=130005;
		$where_p['info_id']=array('exp','is NULL');
		$pro=$db_project->where($where_p)->group('id')->select();
		foreach($pro as $ka=>$va){
			$project[]=$va['id'];
		}
		
		$where_uu['uid']=$this->login_id;
		$where_uu['pid']=array('exp','is not NULL');
		if(empty($_REQUEST['end'])){
			$where_uu['_string']="(('".$_REQUEST['start']."'>=come_date and '".$_REQUEST['start']."'<`out_date`) or ('".$_REQUEST['start']."'>=come_date and out_date is NULL))";
		}else{
			$where_uu['_string']="(('".$_REQUEST['start']."'<=come_date and '".$_REQUEST['end']."'>`out_date`) or ('".$_REQUEST['start']."'<=come_date and out_date is NULL))";
		}
		$puser=$db_project_user->where($where_uu)->group('pid')->select();
		foreach($puser as $ka=>$va){
			$project[]=$va['pid'];
		}
		$project=array_unique($project);
		rsort($project);
		$where_ps['id']=array('in',join(',',$project));
		$where_ps['status']=1;
		if($this->login_id==1){unset($where_ps);$where_ps['status']=1;$where_ps['center_id']=130005;$where_ps['info_id']=array('exp','is NULL');}
		$plist=$db_project->where($where_ps)->group('id')->order('id desc')->select();
		$this->assign('plist',$plist);
		//填报岗位
		$fill_post=$this->get_db_universal_type(12);
		$this->assign('fill_post',$fill_post);
		if($_REQUEST['type']=='1' or $_REQUEST['type']=='2' or $data['type']=='1' or $data['type']=='2'){
			//工作类型
			$work_type=$this->get_db_universal_type(13);
			$this->assign('work_type',$work_type);
			$this->display('schedule_add_zg');
		}elseif($_REQUEST['type']=='3' or $data['type']=='3'){
			//审核人员
			$audit_user=$this->audit_user(4,$audit['audit_type']);
			foreach($audit_user as $kk=>$vv){
				if($audit['status']>$vv['audit_sort']){
					switch($vv['audit_name']){
						case '日程管理负责人':
							$audit_user[$kk]['audit_user']=$this->get_username($audit['audit2_uid']);
							$audit_user[$kk]['audit_date']=$audit['audit2_date'];
						break;
					}
				}
				if(empty($vv['audit_uid']) and empty($audit_user[$kk]['audit_user'])){unset($audit_user[$kk]);}
			}
			//判断项目负责人是否离职
			$judge_user1_user=$this->get_user($pj['manager_uid']);
			if($judge_user1_user['status']!=1)
			{
				$pj['manager_name']=$pj['manager_name'].'(离职)';
			}
			$array1=array("audit_name"=>"项目负责人","audit_user"=>"".$pj['manager_name']."","audit_date"=>"".$audit['audit1_date']."");
			array_unshift($audit_user,$array1);
			$array2=array("audit_name"=>"添加人","audit_user"=>"".$this->get_username($audit['add_uid'])."","audit_date"=>"".$audit['add_date']."");
			array_unshift($audit_user,$array2);
			$this->assign('sum',count($audit_user));
			$this->assign('audit_user',$audit_user);
			$this->display('schedule_add_xx');
		}elseif($_REQUEST['type']=='4' or $data['type']=='4'){
			$this->display('schedule_add_qj');
		}
	}
	
	//日程管理列表-->添加提交 designed by:zhaoshihao 2017-12-05
	function schedule_list_doadd(){
		$db_schedule=M('db_schedule');
		$db_schedule_detail=M('db_schedule_detail');
		//判断日期内填报类型是否有重复
		if(empty($_REQUEST['end'])){
			$where_b['date']=$_REQUEST['start'];
			$where_b['add_uid']=$this->login_id;
			$have=$db_schedule->field('db_schedule.type')->where($where_b)->join('left join db_schedule_detail on db_schedule.id=db_schedule_detail.mid')->group('db_schedule.id')->select();
			foreach($have as $key=>$val){
				if($val['type']==$_REQUEST['type']){
					$data['status']=self::NO;
					echo json_encode($data);die;
				}
			}
		}else{
			$where_a['date']=array('between',array($_REQUEST['start'],$_REQUEST['end']));
			$where_a['add_uid']=$this->login_id;
			$datas=$db_schedule->field('db_schedule.type')->where($where_a)->join('left join db_schedule_detail on db_schedule.id=db_schedule_detail.mid')->group('db_schedule.id')->select();
			foreach($datas as $key=>$val){
				if($val['type']==$_REQUEST['type']){
					$data['status']=self::NO;
					echo json_encode($data);die;
				}
			}
		}
		$db_schedule=M('db_schedule');
		$where['pid']=$_REQUEST['pid'];
		$where['fill_post']=$_REQUEST['fill_post'];
		$where['type']=$_REQUEST['type'];
		if(!empty($_REQUEST['matter_id'])){$where['matter_id']=$_REQUEST['matter_id'];}
		if(!empty($_REQUEST['work_type'])){$where['work_type']=$_REQUEST['work_type'];}
		if(!empty($_REQUEST['work_content'])){$where['work_content']=$_REQUEST['work_content'];}
		if(!empty($_REQUEST['agent_post'])){
			$where['agent']=$_REQUEST['agent_name'];
			$where['agent_post']=$_REQUEST['agent_post'];
			$where['agent_tel']=$_REQUEST['agent_tel'];
		}else{
			if(!empty($_REQUEST['agent'])){$where['agent']=$_REQUEST['agent'];}
		}
		if(!empty($_REQUEST['ekp'])){$where['ekp']=$_REQUEST['ekp'];}
		$where['add_uid']=$this->login_id;
		$where['add_date']=date('Y-m-d H:i:s');
		$result_bool=$db_schedule->add($where);
		//是休息插入审核表
		if($_REQUEST['type']==3){
			$db_audit_main=M('db_audit_main');
			$field='XX';
			$where_s['type']=3;
			$where_s['order_number']=array('like',$field.date('Ymd').'%');
			$result=$db_audit_main->field('order_number')->where($where_s)->order('order_number desc')->find();
			if(empty($result))
			{
				$item=$field.date('Ymd').'001';
			}
			else
			{
				$item=$field.(substr($result['order_number'],2)+1);
			}
			$where_au['pid']=$_REQUEST['pid'];
			$where_au['audit_id']=$result_bool;
			$where_au['order_number']=$item;
			$pd=$this->get_project($_REQUEST['pid']);
			$where_au['audit_type']=$pd['center_id'];
			$where_au['status']=1;
			$where_au['type']=4;
			$where_au['add_uid']=$this->login_id;
			$where_au['add_date']=date('Y-m-d H:i:s');
			$where_au['post_uid']=$this->login_id;
			$where_au['post_date']=date('Y-m-d H:i:s');
			$db_audit_main->add($where_au);
		}
		//副表
		if(empty($_REQUEST['end'])){
			$where_d['mid']=$result_bool;
			$where_d['date']=$_REQUEST['start'];
			$timearray=explode("-",$_REQUEST['start']);
			$where_d['year']=$timearray[0];
			$where_d['month']=$timearray[1];
			$where_d['day']=$timearray[2];
			$where_d['week']=date('W',strtotime($_REQUEST['start']));
			$db_schedule_detail->add($where_d);
		}else{
			$start_date = strtotime($_REQUEST['start']);
			$end_date = strtotime($_REQUEST['end']);
			// 计算日期段内有多少天
			$days = ($end_date-$start_date)/86400+1;
			// 保存每天日期
			$date = array();
			for($i=0; $i<$days; $i++){
				$date[] = date('Y-m-d', $start_date+(86400*$i));
			}
			foreach($date as $key=>$val){
				$where_d['mid']=$result_bool;
				$where_d['date']=$val;
				$timearray=explode("-",$val);
				$where_d['year']=$timearray[0];
				$where_d['month']=$timearray[1];
				$where_d['day']=$timearray[2];
				$where_d['week']=date('W',strtotime($val));
				$db_schedule_detail->add($where_d);
			}
		}
		if($result_bool)
		{
			$data['status']=self::YES;
		}
		else
		{
			$data['status']=self::NO;
		}
		echo json_encode($data);die;
	}
	
	//日程管理列表-->编辑/详情 designed by:zhaoshihao 2017-12-05
	function schedule_list_edit(){
		$db_schedule=M('db_schedule');
		$where['id']=$_REQUEST['id'];
		$data['detail']=$db_schedule->where($where)->find();
		$db_schedule_detail=M('db_schedule_detail');
		$where_d['mid']=$_REQUEST['id'];
		$detail=$db_schedule_detail->where($where_d)->order('date')->select();
		foreach($detail as $key=>$val){
			$second1=strtotime($val['date']);
			$second2=strtotime(date('Y-m-d'));
			if(($second1-$second2)/86400>7){
				$data['detail']['noedit']=1;
			}
			if(($second2-$second1)/86400>7){
				$data['detail']['noedit']=1;
			}
			$date[]=$val['date'];
			if($key==0){
				$data['detail']['show_date']=$val['date'];
			}
			if(count($detail)!=1){
				if($key+1==count($detail)){
				$data['detail']['show_date'].='~'.$val['date'];
				}
			}
			if(count($detail)==1){
				$data['detail']['date']=$val['date'];
			}
		}
		$pd=$this->get_project($data['detail']['pid']);
		$data['detail']['project']='['.$pd['project_num'].']'.$pd['project_name'];
		$fill_post_name=$this->get_db_universal_type(12,1,NULL,NULL,$data['fill_post']);
		$data['detail']['fill_post_name']=$fill_post_name['name2'];
		sort($date);
		$start=reset($date);
		$end=end($date);
		if(count($detail)>1){
			$data['detail']['start_date']=$start;
			$data['detail']['end_date']=$end;
		}
		$type_name=$this->get_db_universal_type(11,1,NULL,NULL,$data['detail']['type']);
		$data['detail']['type_name']=$type_name['name2'];
		//休息审核
		$db_audit_main=M('db_audit_main');
		$where_m['audit_id']=$_REQUEST['id'];
		$where_m['type']=4;
		$audit=$db_audit_main->where($where_m)->find();
		$data['detail']['order_number']=$audit['order_number'];
		$data['detail']['audit_type']=$audit['audit_type'];
		$data['detail']['status']=$audit['status'];
		$data['detail']['audit_id']=$audit['id'];
		//所有项目
		$project=array();
		$db_project_user=M('db_project_user');
		$db_project=M('db_project');
		
		$where_p['_string']="(manager_uid=".$this->login_id.") or (director_uid=".$this->login_id.")";
		$where_p['status']=1;
		$where_p['center_id']=130005;
		$where_p['info_id']=array('exp','is NULL');
		$pro=$db_project->where($where_p)->group('id')->select();
		foreach($pro as $ka=>$va){
			$project[]=$va['id'];
		}
		
		$where_u['uid']=$this->login_id;
		$where_u['pid']=array('exp','is not NULL');
		if(count($detail)==1){
			$where_u['_string']="(('".$start."'>=come_date and '".$start."'<`out_date`) or ('".$start."'>=come_date and out_date is NULL))";
		}else{
			$where_u['_string']="(('".$start."'<=come_date and '".$end."'>`out_date`) or ('".$start."'<=come_date and out_date is NULL))";
		}
		$puser=$db_project_user->where($where_u)->group('pid')->select();
		foreach($puser as $ka=>$va){
			$project[]=$va['pid'];
		}
		$project=array_unique($project);
		rsort($project);
		$where_ps['id']=array('in',join(',',$project));
		$where_ps['status']=1;
		if($this->login_id==1){unset($where_ps);$where_ps['status']=1;$where_ps['center_id']=130005;$where_ps['info_id']=array('exp','is NULL');}
		$project_list=$db_project->where($where_ps)->order('id desc')->select();
		$data['plist']=$project_list;
		//填报岗位
		$data['fill_post']=$this->get_db_universal_type(12);
		//工作类型
		$data['work_type']=$this->get_db_universal_type(13);
		echo json_encode($data);die;
	}
	
	//日程管理列表-->编辑提交 designed by:zhaoshihao 2017-12-05
	function schedule_list_doedit(){
		$db_schedule=M('db_schedule');
		$where['id']=$_REQUEST['id'];
		$asd=$db_schedule->where($where)->find();
		$where['pid']=$_REQUEST['pid'];
		$where['fill_post']=$_REQUEST['fill_post'];
		if(!empty($_REQUEST['matter_id'])){$where['matter_id']=$_REQUEST['matter_id'];}
		if(!empty($_REQUEST['work_type'])){$where['work_type']=$_REQUEST['work_type'];}
		if(!empty($_REQUEST['work_content'])){$where['work_content']=$_REQUEST['work_content'];}
		if(!empty($_REQUEST['agent_name'])){
			$where['agent']=$_REQUEST['agent_name'];
			$where['agent_post']=$_REQUEST['agent_post'];
			$where['agent_tel']=$_REQUEST['agent_tel'];
		}else{
			$where['agent']=$_REQUEST['agent'];
			$where['agent_post']=NULL;
			$where['agent_tel']=NULL;
		}
		if(!empty($_REQUEST['ekp'])){$where['ekp']=$_REQUEST['ekp'];}
		$result_bool=$db_schedule->save($where);
		if($asd['type']==3){
			$db_audit_main=M('db_audit_main');
			$where_sa['audit_id']=$_REQUEST['id'];
			$where_sa['type']=4;
			$where_au['pid']=$_REQUEST['pid'];
			$pd=$this->get_project($_REQUEST['pid']);
			$where_au['audit_type']=$pd['center_id'];
			$where_au['status']=1;
			$where_au['post_uid']=$this->login_id;
			$where_au['post_date']=date('Y-m-d H:i:s');
			$db_audit_main->where($where_sa)->save($where_au);
		}
		if($result_bool)
		{
			$data['status']=self::YES;
		}
		else
		{
			$data['status']=self::NO;
		}
		echo json_encode($data);die;
	}
	
	//日程管理列表-->ajax designed by:zhaoshihao 2017-12-05
	function schedule_list_ajax(){
		if($_REQUEST['action']=='type'){
			//填报类型
			$type=$this->get_db_universal_type(11);
			$db_schedule=M('db_schedule');
			$db_schedule_detail=M('db_schedule_detail');
			if(empty($_REQUEST['date'])){
				$start=$_REQUEST['start'];
				$end=$_REQUEST['end'];
				$where_a['date']=array('between',array($start,$end));
			}else{
				$where_a['date']=$_REQUEST['date'];
			}
			$where_a['add_uid']=$this->login_id;
			$datas=$db_schedule->field('db_schedule.*')->where($where_a)->join('left join db_schedule_detail on db_schedule.id=db_schedule_detail.mid')->group('db_schedule.id')->select();
			foreach($datas as $key=>$val){
				foreach($type as $kk=>$vv){
					if($val['type']==$vv['name1']){
						unset($type[$kk]);
					}
				}
			}
			if(!empty($type)){
				$data['has_type']=1;
				foreach($type as $kk=>$vv){
					$data['way']=$vv['name1'];
					break;
				}
			}
			$type=array_values($type);
			$data['type']=$type;
			$data['fill_post']=$this->get_db_universal_type(12);
			$data['work_type']=$this->get_db_universal_type(13);
			//填报项目筛选
			//所有项目
			$project=array();
			$db_project_user=M('db_project_user');
			$db_project=M('db_project');
			
			$where_p['_string']="(manager_uid=".$this->login_id.") or (director_uid=".$this->login_id.")";
			$where_p['status']=1;
			$where_p['center_id']=130005;
			$where_p['info_id']=array('exp','is NULL');
			$pro=$db_project->where($where_p)->group('id')->select();
			foreach($pro as $ka=>$va){
				$project[]=$va['id'];
			}
			
			$where_u['uid']=$this->login_id;
			$where_u['pid']=array('exp','is not NULL');
			if(!empty($_REQUEST['date'])){
				$where_u['_string']="(('".$_REQUEST['date']."'>=come_date and '".$_REQUEST['date']."'<`out_date`) or ('".$_REQUEST['date']."'>=come_date and out_date is NULL))";
			}else{
				$where_u['_string']="(('".$_REQUEST['start']."'<=come_date and '".$_REQUEST['end']."'>`out_date`) or ('".$_REQUEST['start']."'<=come_date and out_date is NULL))";
			}
			$puser=$db_project_user->where($where_u)->group('pid')->select();
			foreach($puser as $ka=>$va){
				$project[]=$va['pid'];
			}
			$project=array_unique($project);
			rsort($project);
			$where_ps['id']=array('in',join(',',$project));
			$where_ps['status']=1;
			if($this->login_id==1){unset($where_ps);$where_ps['status']=1;$where_ps['center_id']=130005;$where_ps['info_id']=array('exp','is NULL');}
			$data['plist']=$db_project->where($where_ps)->group('id')->order('id desc')->select();
			echo json_encode($data);die;
		}elseif($_REQUEST['action']=='user'){
			$db_schedule_detail=M('db_schedule_detail');
			//休息选择项目人员
			if(!empty($_REQUEST['mid'])){
				
				$where_d['mid']=$_REQUEST['mid'];
				$detail=$db_schedule_detail->where($where_d)->order('date')->select();
				foreach($detail as $key=>$val){
					if($key==0){
						$show_date=$val['date'];
					}
					if(count($detail)!=1){
						if($key+1==count($detail)){
							$show_date2=$val['date'];
						}
					}
				}
				if(!empty($show_date2)){
					$where['_string']="(('".$show_date."'<=come_date and '".$show_date2."'>`out_date`) or ('".$show_date."'<=come_date and out_date is NULL))";
				}else{
					$where['_string']="(('".$show_date."'>=come_date and '".$show_date."'<`out_date`) or ('".$show_date."'>=come_date and out_date is NULL))";
				}
			}else{
				if(empty($_REQUEST['end'])){
					$where['_string']="(('".$_REQUEST['start']."'>=come_date and '".$_REQUEST['start']."'<`out_date`) or ('".$_REQUEST['start']."'>=come_date and out_date is NULL))";
				}else{
					$where['_string']="(('".$_REQUEST['start']."'<=come_date and '".$_REQUEST['end']."'>`out_date`) or ('".$_REQUEST['start']."'<=come_date and out_date is NULL))";
				}
			}
			//姓名下拉菜单
			$pj=$this->get_project($_REQUEST['id']);
			$use=array();
			$use[]=$pj['manager_uid'];
			$use[]=$pj['director_uid'];
			$db_project_user=M('db_project_user');
			$where['pid']=$_REQUEST['id'];
			$result=$db_project_user->where($where)->order('come_date desc')->group('uid')->select();
			foreach($result as $key=>$value){
				if($value['uid']!=$this->login_id){
					$use[]=$value['uid'];
				}
			}
			$use=array_flip(array_flip($use));
			$uses=join(',',$use);
			$data=$this->get_all_username(1,NULL,NULL,NULL,$uses);
			foreach($data as $key=>$value){
				$user=$this->get_user($value['id']);
				$data[$key]['position']=$user['position_descr'];
				$data[$key]['mobilephone']=$user['mobilephone'];
			}
			echo json_encode($data);die;
		}elseif($_REQUEST['action']=='detail'){
			//日历显示数据
			$db_schedule=M('db_schedule');
			$db_schedule_detail=M('db_schedule_detail');
			//$timearray=explode("-",$_REQUEST['date']);
			//$year=$timearray[0];
			//$month=$timearray[1];
			$month=$_REQUEST['month']+1;
			$firstday=$this->get_date(NULL,"-1 month",$_REQUEST['year'].'-'.$month);
			$lastday=$this->get_date(NULL,"+1 month",$_REQUEST['year'].'-'.$month);
			$lastday=date('Y-m-d', strtotime("$lastday +1 month -1 day"));
			$where_a['date']=array('between',array($firstday,$lastday));
			$where_a['add_uid']=$this->login_id;
			$data=$db_schedule->field('db_schedule.*')->where($where_a)->join('left join db_schedule_detail on db_schedule.id=db_schedule_detail.mid')->group('db_schedule.id')->order('date')->select();
			foreach($data as $kk=>$vv){
				$project=$this->get_project($vv['pid']);
				$data[$kk]['project_name']=$project['project_name'];
				$where_de['mid']=$vv['id'];
				$where_de['date']=array('between',array($firstday,$lastday));
				$detail=$db_schedule_detail->where($where_de)->order('date')->select();
				if(count($detail)==1){
					$data[$kk]['date']=str_replace(array('/'),'-',$detail[0]['date']);
				}else{
					$data[$kk]['start_date']=str_replace(array('/'),'-',$detail[0]['date']);
					$end_date=$detail[count($detail)-1]['date'];
					$data[$kk]['end_date']=str_replace(array('/'),'-',$end_date);
				}
				if($vv['type']==1){
					$data[$kk]['color']='#a9d26a';
				}elseif($vv['type']==2){
					$data[$kk]['color']='#4680fe';
				}elseif($vv['type']==3){
					$data[$kk]['color']='#fb607f';
				}elseif($vv['type']==4){
					$data[$kk]['color']='#8d81c9';
				}
			}
			$data['date']=$data;
			echo json_encode($data);die;
		}elseif($_REQUEST['action']=='list'){
			//点击日期前7天详情加载
			$db_schedule=M('db_schedule');
			$db_schedule_detail=M('db_schedule_detail');
			//$time=date("Y-m-d",time($_REQUEST['dates']));
			//$ldates=date('Y-m-d',strtotime("$time - 7 day"));
			$ldate=$_REQUEST['dates'];
			$ldates=date('Y-m-d',strtotime("$ldate - 7 day"));
			$where_a['date']=array('between',array($ldates,$_REQUEST['dates']));
			$where_a['add_uid']=$this->login_id;
			$data=$db_schedule->field('db_schedule.*')->where($where_a)->join('left join db_schedule_detail on db_schedule.id=db_schedule_detail.mid')->group('db_schedule.id')->order('date')->select();
			foreach($data as $kk=>$vv){
				//工作类型
				$work_type_name=$this->get_db_universal_type(13,1,NULL,NULL,$vv['work_type']);
				$data[$kk]['work_name']=$work_type_name['name2'];
				//填报类型
				$type_name=$this->get_db_universal_type(11,1,NULL,NULL,$vv['type']);
				$data[$kk]['type_name']=$type_name['name2'];
				//
				$fill_post_name=$this->get_db_universal_type(12,1,NULL,NULL,$vv['fill_post']);
				$data[$kk]['fill_post_name']=$fill_post_name['name2'];
				//休息人员
				$userd=$this->get_user($vv['agent']);
				$data[$kk]['agent_name']=$userd['username'];
				$data[$kk]['position']=$userd['position_descr'];
				$data[$kk]['mobilephone']=$userd['mobilephone'];
				//日期
				$where_de['mid']=$vv['id'];
				$where_de['date']=array('between',array($ldates,$_REQUEST['dates']));
				$detail=$db_schedule_detail->where($where_de)->order('date')->select();
				foreach($detail as $kkk=>$vvv){
					if($kkk==0){
						$data[$kk]['show_date']=$vvv['date'];
					}
					if(count($detail)!=1){
						if($kkk+1==count($detail)){
						$data[$kk]['show_date'].=' ~ '.$vvv['date'];
						}
					}
					$second1=strtotime($vvv['date']);
					$second2=strtotime(date('Y-m-d'));
					if(($second1-$second2)/86400>7){
						$data[$kk]['noedit']=1;
					}
					if(($second2-$second1)/86400>7){
						$data[$kk]['noedit']=1;
					}
				}
				//项目
				$pd=$this->get_project($vv['pid']);
				$data[$kk]['project_num']=$pd['project_num'];
				$data[$kk]['project_name']=$pd['project_name'];
				//休息审核
				$db_audit_main=M('db_audit_main');
				$where_m['audit_id']=$vv['id'];
				$where_m['type']=4;
				$audit=$db_audit_main->where($where_m)->find();
				$data[$kk]['order_number']=$audit['order_number'];
				$data[$kk]['audit_type']=$audit['audit_type'];
				$data[$kk]['status']=$audit['status'];
				$data[$kk]['dh_date']=$audit['dh_date'];
				$data[$kk]['dh_message']=$audit['dh_message'];
				$data[$kk]['arrive_status']=$audit['arrive_status'];
				$data[$kk]['submit_info']=$audit['submit_info'];
				$data[$kk]['dh_user']=$this->get_username($audit['dh_uid']);
				if($audit['status']>1){$data[$kk]['noedit']=1;}
				$data[$kk]['audit_id']=$audit['id'];
			}
			echo json_encode($data);die;
		}elseif($_REQUEST['action']=='dates'){
			//判断点击日期是否在14天内
			$second1=strtotime($_REQUEST['date']);
			$second2=strtotime(date('Y-m-d'));
			if(($second1-$second2)/86400>7){
				$data['nodate']=1;
			}
			if(($second2-$second1)/86400>7){
				$data['nodate']=1;
			}
			$data['date']=$_REQUEST['date'];
			echo json_encode($data);die;
		}elseif($_REQUEST['action']=='details'){
			/*
			//单条详情
			$db_schedule=M('db_schedule');
			$where['id']=$_REQUEST['id'];
			$data=$db_schedule->where($where)->find();
			$db_schedule_detail=M('db_schedule_detail');
			$where_d['mid']=$_REQUEST['id'];
			$detail=$db_schedule_detail->where($where_d)->order('date')->select();
			foreach($detail as $key=>$val){
				$second1=strtotime($val['date']);
				$second2=strtotime(date('Y-m-d'));
				if(($second1-$second2)/86400>7){
					$data['noedit']=1;
				}
				if(($second2-$second1)/86400>7){
					$data['noedit']=1;
				}
				if($key==0){
					$data['detail']['show_date']=$val['date'];
				}
				if(count($detail)!=1){
					if($key+1==count($detail)){
					$data['detail']['show_date'].='~'.$val['date'];
					}
				}
			}
			//项目
			$pd=$this->get_project($data['pid']);
			$data['project_num']=$pd['project_num'];
			$data['project_name']=$pd['project_name'];
			//工作类型
			$work_type_name=$this->get_db_universal_type(13,1,NULL,NULL,$data['work_type']);
			if(!empty($data)){
				$data['work_type_name']=$work_type_name['name3'];
				$data['work_name']=$work_type_name['name2'];
				$userd=$this->get_user($data['agent']);
				$data['agent_name']=$userd['username'];
				$data['position']=$this->get_db_universal_label(2,$userd['position_id']);
				$data['mobilephone']=$userd['mobilephone'];
				$type_name=$this->get_db_universal_type(11,1,NULL,NULL,$data['type']);
				$data['type_name']=$type_name['name2'];
			}
			//休息审核
			$db_audit_main=M('db_audit_main');
			$where_m['audit_id']=$_REQUEST['id'];
			$where_m['type']=4;
			$audit=$db_audit_main->where($where_m)->find();
			$data['order_number']=$audit['order_number'];
			$data['audit_type']=$audit['audit_type'];
			$data['status']=$audit['status'];
			if($data['status']>1){$data['noedit']=1;}
			$data['audit_id']=$audit['id'];
			echo json_encode($data);die;
			*/
		}elseif($_REQUEST['action']=='next'){
			//判断选择的日期内填报类型是否有重复
			$db_schedule=M('db_schedule');
			if(empty($_REQUEST['end'])){
				$where['date']=$_REQUEST['start'];
				$where['add_uid']=$this->login_id;
				$have=$db_schedule->field('db_schedule.type')->where($where)->join('left join db_schedule_detail on db_schedule.id=db_schedule_detail.mid')->group('db_schedule.id')->select();
				foreach($have as $key=>$val){
					if($val['type']==$_REQUEST['type']){
						$data['status']=0;
						$data['msg']='重复填报类型';
						echo json_encode($data);die;
					}
				}
			}else{
				$where_a['date']=array('between',array($_REQUEST['start'],$_REQUEST['end']));
				$where_a['add_uid']=$this->login_id;
				$datas=$db_schedule->field('db_schedule.type')->where($where_a)->join('left join db_schedule_detail on db_schedule.id=db_schedule_detail.mid')->group('db_schedule.id')->select();
				foreach($datas as $key=>$val){
					if($val['type']==$_REQUEST['type']){
						$data['status']=0;
						$data['msg']='重复填报类型';
						echo json_encode($data);die;
					}
				}
			}
			$data['status']=1;
			echo json_encode($data);die;
		}
	}
	
	//日程管理列表-->删除 designed by:zhaoshihao 2017-12-05
	function schedule_list_action(){
		$db_schedule=M('db_schedule');
		$where['id']=$_REQUEST['id'];
		$db_schedule->where($where)->delete();
		$db_schedule_detail=M('db_schedule_detail');
		$where_s['mid']=$_REQUEST['id'];
		$db_schedule_detail->where($where_s)->delete();
		$db_audit_main=M('db_audit_main');
		$where_m['audit_id']=$_REQUEST['id'];
		$where_m['type']=4;
		$db_audit_main->where($where_m)->delete();
		$data['status']=self::YES;
		echo json_encode($data);die;
	}
	
	//日程管理列表审核ajax designed by:zhaoshihao 2017-12-05
	function schedule_list_audit_ajax(){
		$db_audit_main=M('db_audit_main');
		$status=$_REQUEST['status'];
		$up_wheres['audit_id']=$_REQUEST['mid'];
		$up_wheres['type']=4;
		$find_result=$db_audit_main->where($up_wheres)->find();
		$project=$this->get_project($find_result['pid']);
		if($_REQUEST['state']==1 or (($_REQUEST['state']==-10) and (!empty($_REQUEST['uuid'])))){
			$sta=$this->audit_type_next_person(4,$find_result['audit_type'],$status,'egt');
			if($find_result['flow_status']==-1){
				if($find_result['status']==$find_result['arrive_status']){
					$status=$find_result['dh_status'];
				}
			}
		}elseif($_REQUEST['state']==2 or (($_REQUEST['state']==-10) and (empty($_REQUEST['uuid'])))){
			if(($project['manager_uid']==$this->login_id) and ($find_result['status']==2)){
				$status=1;
				$sta['audit_sort']=1;
			}else{
				$sta=$this->audit_type_next_person(4,$find_result['audit_type'],$status,'lt');
				$status=$sta['audit_sort'];
			}
		}
		switch($status){
			case -1:
				if($_REQUEST['flow_status']==-1){
					$up_where=$this->audit_status_judge($_REQUEST['arrive_status']);
					$up_where['status']=$_REQUEST['arrive_status'];
					$up_where['id']=$_REQUEST['mid'];
				}else{
					$up_where['status']=-1;
					$up_where['audit1_uid']=NULL;$up_where['audit1_date']=NULL;$up_where['audit1_message']=NULL;
					$up_where['audit2_uid']=NULL;$up_where['audit2_date']=NULL;$up_where['audit2_message']=NULL;
				}
				if(!empty($_REQUEST['dh_message']))
				{
					$up_where['dh_uid']=$this->login_id;
					$up_where['dh_date']=date('Y-m-d H:i:s');
					$up_where['dh_message']=$_REQUEST['dh_message'];
					$up_where['dh_status']=$_REQUEST['dh_status'];
					$up_where['arrive_status']=$_REQUEST['arrive_status'];
					$up_where['flow_status']=$_REQUEST['flow_status'];
					$up_where['submit_info']=NULL;
				}else{
					if($find_result['status']!=1){
						unset($up_where);
					}
				}
				break;
			case 1:
				$up_where['status']=$sta['audit_sort'];
				$up_where['audit1_uid']=NULL;$up_where['audit1_date']=NULL;$up_where['audit1_message']=NULL;
				$up_where['audit2_uid']=NULL;$up_where['audit2_date']=NULL;$up_where['audit2_message']=NULL;
				if(!empty($_REQUEST['uuid'])){
					if($find_result['status']!=-1){
						unset($up_where);
					}else{
						$up_where['flow_status']=1;
						$up_where['status']=1;
						$up_where['post_uid']=$this->login_id;
						$up_where['post_date']=date('Y-m-d H:i:s');
					}
				}else{
					$up_where['status']=1;
					if($sta['audit_sort']!=$status){
						unset($up_where);
					}
				}
				break;
			case 2:
				$up_where['audit2_uid']=NULL;$up_where['audit2_date']=NULL;$up_where['audit2_message']=NULL;
				if(!empty($_REQUEST['uuid'])){
					if($find_result['flow_status']==-1 and $find_result['status']==$find_result['arrive_status']){
						$up_where['status']=$status;
						$up_where['flow_status']=1;
						if($find_result['status']!=$find_result['arrive_status']){
							unset($up_where);
						}else{
							if($find_result['arrive_status']==-1){
								$up_where['post_uid']=$this->login_id;
								$up_where['post_date']=date('Y-m-d H:i:s');
							}else{
								$up_where['audit'.$find_result['arrive_status'].'_uid']=$this->login_id;
								$up_where['audit'.$find_result['arrive_status'].'_date']=date('Y-m-d H:i:s');
								$up_where['audit'.$find_result['arrive_status'].'_message']=$_REQUEST['audit1_message'];
								$up_where['submit_info']=$_REQUEST['audit1_message'];
							}
						}
					}else{
						$up_where['status']=$sta['audit_sort'];
						if($find_result['status']!=1){
							unset($up_where);
						}else{
							$up_where['audit1_uid']=$this->login_id;
							$up_where['audit1_date']=date('Y-m-d H:i:s');
							$up_where['audit1_message']=$_REQUEST['audit1_message'];
						}
					}
				}else{
					$up_where['status']=$status;
					if($find_result['flow_status']==-1){
						if($find_result['dh_status']!=$status){
							unset($up_where);
						}
					}else{
						if($sta['audit_sort']!=$status){
							unset($up_where);
						}
					}
				}
				break;
			case 3:
				if($find_result['status']!=2){
					unset($up_where);
				}else{
					$up_where['status']=$status;
					$up_where['audit2_uid']=$this->login_id;
					$up_where['audit2_date']=date('Y-m-d H:i:s');
					$up_where['audit2_message']=$_REQUEST['audit_message'];
				}
				break;
		}
		if($_REQUEST['submit_info']){$up_where['submit_info']=$_REQUEST['submit_info'];}
		$data['status']=$db_audit_main->where($up_wheres)->save($up_where);
		$data['state']=$_REQUEST['state'];
		echo json_encode($data);die;
	}
	
	//会议纪要 designed by:zhaoshihao 2017-10-17
	function meeting_minutes_list(){
		//赋值
		$center_id=I('center_id',-10);
		$db_meeting_minutes=M('db_meeting_minutes');
		if(get_permission('HY',1)){
			if($center_id!=-10){$where['center_id']=$center_id;}
			if(get_permission('HY',NULL,2)){
				if($center_id!=-10){
					if($center_id==$this->login_center_id){
					}else{
						$where['db_meeting_minutes.status']=1;
					}
				}else{
					$where['_string']="(center_id=".$this->login_center_id.") or (db_meeting_minutes.status=1) ";
				}
			}elseif(get_permission('HY',NULL,3)){
				$where['_string']="(add_uid=".$this->login_id.") or (db_meeting_minutes.status=1)";
			}elseif(get_permission('HY',NULL,4)){
				$where['db_meeting_minutes.status']=1;
			}
		}elseif(get_permission('HY',2)){
			if(get_permission('HY',NULL,2)){
				if($center_id!=-10){
					if($center_id==$this->login_center_id){
						$where['_string']="((((db_meeting_minutes.status=-1) and ((center_id=".$center_id.") or (add_uid=".$this->login_id."))) or ((uid=".$this->login_id.") and (db_meeting_minutes.status=1))) and (center_id=".$center_id.")) or (center_id=".$center_id.")";
					}else{
						$where['_string']="(((db_meeting_minutes.status=-1) and (add_uid=".$this->login_id.")) or ((uid=".$this->login_id.") and (db_meeting_minutes.status=1))) and (center_id=".$center_id.")";
					}
				}else{
					$where['_string']="((db_meeting_minutes.status=-1) and ((center_id=".$this->login_center_id.") or (add_uid=".$this->login_id."))) or ((uid=".$this->login_id.") and (db_meeting_minutes.status=1)) or (center_id=".$this->login_center_id.")";
				}
			}elseif(get_permission('HY',NULL,3)){
				if($center_id!=-10){
					if($center_id==$this->login_center_id){
						$where['_string']="((((db_meeting_minutes.status=-1) and (add_uid=".$this->login_id.")) or ((uid=".$this->login_id.") and (db_meeting_minutes.status=1))) and (center_id=".$center_id.")) or (center_id=".$center_id.")";
					}else{
						$where['_string']="(((db_meeting_minutes.status=-1) and (add_uid=".$this->login_id.")) or ((uid=".$this->login_id.") and (db_meeting_minutes.status=1))) and (center_id=".$center_id.")";
					}
				}else{
					$where['_string']="((db_meeting_minutes.status=-1) and (add_uid=".$this->login_id.")) or ((uid=".$this->login_id.") and (db_meeting_minutes.status=1)) or (center_id=".$this->login_center_id.")";
				}
			}elseif(get_permission('HY',NULL,4)){
				if($center_id!=-10){
					if($center_id==$this->login_center_id){
						$where['_string']="(((uid=".$this->login_id.") and (db_meeting_minutes.status=1)) and (center_id=".$center_id.")) or (center_id=".$center_id.")";
					}else{
						$where['_string']="(uid=".$this->login_id.") and (db_meeting_minutes.status=1) and (center_id=".$center_id.")";
					}
				}else{
					$where['_string']="((uid=".$this->login_id.") and (db_meeting_minutes.status=1)) or (center_id=".$this->login_center_id.")";
				}
			}
		}elseif(get_permission('HY',3)){
			if($center_id!=-10){$where['center_id']=$center_id;}
			if(get_permission('HY',NULL,3)){
				$where['_string']="((db_meeting_minutes.status=-1) and (add_uid=".$this->login_id.")) or ((uid=".$this->login_id.") and (db_meeting_minutes.status=1))";
			}elseif(get_permission('HY',NULL,4)){
				$where['_string']="(uid=".$this->login_id.") and (db_meeting_minutes.status=1)";
			}
		}else{
			if($center_id!=-10){$where['center_id']=$center_id;}
			$where['uid']=$this->login_id;
			$where['db_meeting_minutes.status']=1;
		}
		$result=$db_meeting_minutes->field('db_meeting_minutes.*')->where($where)->join('left join db_meeting_minutes_detail on db_meeting_minutes.id=db_meeting_minutes_detail.mid')->limit(6)->order('db_meeting_minutes.id desc')->group('db_meeting_minutes.id')->select();
		$count=$db_meeting_minutes->field('db_meeting_minutes.id')->where($where)->join('left join db_meeting_minutes_detail on db_meeting_minutes.id=db_meeting_minutes_detail.mid')->group('db_meeting_minutes.id')->select();
		//记录数
		$db_meeting_minutes_module=M('db_meeting_minutes_module');
		foreach($result as $key=>$value)
		{
			$where_m['id']=$value['mb_id'];
			$result[$key]['module']=$db_meeting_minutes_module->where($where_m)->find();
		}
		$this->assign('result',$result);
		$this->assign('count',count($count));
		$this->display();
	}
	
	//会议纪要下拉加载 designed by:zhaoshihao 2017-10-17
	function meeting_minutes_ajax(){
		$center_id=-10;
		$db_meeting_minutes=M('db_meeting_minutes');
		if(get_permission('HY',1)){
			if($center_id!=-10){$where['center_id']=$center_id;}
			if(get_permission('HY',NULL,2)){
				if($center_id!=-10){
					if($center_id==$this->login_center_id){
					}else{
						$where['db_meeting_minutes.status']=1;
					}
				}else{
					$where['_string']="(center_id=".$this->login_center_id.") or (db_meeting_minutes.status=1) ";
				}
			}elseif(get_permission('HY',NULL,3)){
				$where['_string']="(add_uid=".$this->login_id.") or (db_meeting_minutes.status=1)";
			}elseif(get_permission('HY',NULL,4)){
				$where['db_meeting_minutes.status']=1;
			}
		}elseif(get_permission('HY',2)){
			if(get_permission('HY',NULL,2)){
				if($center_id!=-10){
					if($center_id==$this->login_center_id){
						$where['_string']="((((db_meeting_minutes.status=-1) and ((center_id=".$center_id.") or (add_uid=".$this->login_id."))) or ((uid=".$this->login_id.") and (db_meeting_minutes.status=1))) and (center_id=".$center_id.")) or (center_id=".$center_id.")";
					}else{
						$where['_string']="(((db_meeting_minutes.status=-1) and (add_uid=".$this->login_id.")) or ((uid=".$this->login_id.") and (db_meeting_minutes.status=1))) and (center_id=".$center_id.")";
					}
				}else{
					$where['_string']="((db_meeting_minutes.status=-1) and ((center_id=".$this->login_center_id.") or (add_uid=".$this->login_id."))) or ((uid=".$this->login_id.") and (db_meeting_minutes.status=1)) or (center_id=".$this->login_center_id.")";
				}
			}elseif(get_permission('HY',NULL,3)){
				if($center_id!=-10){
					if($center_id==$this->login_center_id){
						$where['_string']="((((db_meeting_minutes.status=-1) and (add_uid=".$this->login_id.")) or ((uid=".$this->login_id.") and (db_meeting_minutes.status=1))) and (center_id=".$center_id.")) or (center_id=".$center_id.")";
					}else{
						$where['_string']="(((db_meeting_minutes.status=-1) and (add_uid=".$this->login_id.")) or ((uid=".$this->login_id.") and (db_meeting_minutes.status=1))) and (center_id=".$center_id.")";
					}
				}else{
					$where['_string']="((db_meeting_minutes.status=-1) and (add_uid=".$this->login_id.")) or ((uid=".$this->login_id.") and (db_meeting_minutes.status=1)) or (center_id=".$this->login_center_id.")";
				}
			}elseif(get_permission('HY',NULL,4)){
				if($center_id!=-10){
					if($center_id==$this->login_center_id){
						$where['_string']="(((uid=".$this->login_id.") and (db_meeting_minutes.status=1)) and (center_id=".$center_id.")) or (center_id=".$center_id.")";
					}else{
						$where['_string']="(uid=".$this->login_id.") and (db_meeting_minutes.status=1) and (center_id=".$center_id.")";
					}
				}else{
					$where['_string']="((uid=".$this->login_id.") and (db_meeting_minutes.status=1)) or (center_id=".$this->login_center_id.")";
				}
			}
		}elseif(get_permission('HY',3)){
			if($center_id!=-10){$where['center_id']=$center_id;}
			if(get_permission('HY',NULL,3)){
				$where['_string']="((db_meeting_minutes.status=-1) and (add_uid=".$this->login_id.")) or ((uid=".$this->login_id.") and (db_meeting_minutes.status=1))";
			}elseif(get_permission('HY',NULL,4)){
				$where['_string']="(uid=".$this->login_id.") and (db_meeting_minutes.status=1)";
			}
		}else{
			if($center_id!=-10){$where['center_id']=$center_id;}
			$where['uid']=$this->login_id;
			$where['db_meeting_minutes.status']=1;
		}
		$start=$_REQUEST['start_size'];
		$end=$_REQUEST['start_page'];
		$data=$db_meeting_minutes->field('db_meeting_minutes.*')->where($where)->join('left join db_meeting_minutes_detail on db_meeting_minutes.id=db_meeting_minutes_detail.mid')->limit($start,$end)->order('db_meeting_minutes.id desc')->group('db_meeting_minutes.id')->select();
		//记录数
		$db_meeting_minutes_module=M('db_meeting_minutes_module');
		foreach($data as $key=>$value)
		{
			$where_m['id']=$value['mb_id'];
			$data[$key]['module']=$db_meeting_minutes_module->where($where_m)->find();
		}
		echo json_encode($data);die;
	}
	
	//会议纪要-->详情 designed by:zhaoshihao 2017-10-17
	function meeting_minutes_detail(){
		$db_meeting_minutes=M('db_meeting_minutes');
		$db_meeting_minutes_detail=M('db_meeting_minutes_detail');
		$db_meeting_minutes_module=M('db_meeting_minutes_module');
		//主表
		$where['id']=$_REQUEST['id'];
		$result=$db_meeting_minutes->where($where)->find();
		$result['center_name']=$this-$this->get_oa_dep_name($result['center_id']);
		$where_h['id']=$result['hy_id'];
		$hy_id=$db_meeting_minutes->where($where_h)->find();
		$result['hy_num']=$hy_id['meeting_num'];
		$result['mb_name']=$hy_id['mb_name'];
		$where_mo['id']=$result['mb_id'];
		$module=$db_meeting_minutes_module->where($where_mo)->find();
		$result['module_name']=$module['module_name'];
		$this->assign('result',$result);
		//会议呈报
		$where_de['db_meeting_minutes_detail.mid']=$_REQUEST['id'];
		$map['db_meeting_minutes_detail.matter']=array('exp','is not NULL');
		$map['db_meeting_minutes_detail.reply']=array('exp','is not NULL');
		$map['db_meeting_minutes_detail.ready_things']=array('exp','is not NULL');
		$map['_logic']='or';
		$where_de['_complex']=$map;
		$where_de['_string']='(db_meeting_minutes_detail.status=1) or ((db_meeting_minutes_detail.status=-1) and (db_meeting_minutes_detail.d_uid is not NULL))';
		$detail=$db_meeting_minutes_detail->where($where_de)->order('sort')->select();
		foreach($detail as $ka=>$va){
			if(!empty($hy_id)){
				$where_gl['mid']=$hy_id['id'];
				$where_gl['uid']=$va['uid'];
				$gl=$db_meeting_minutes_detail->where($where_gl)->find();
				$detail[$ka]['matter_gl']=$gl['matter'];
				$detail[$ka]['reply_gl']=$gl['reply'];
				$detail[$ka]['ready_things_gl']=$gl['ready_things'];
			}
			$detail[$ka]['username']=$this->get_username($va['uid']);
			$detail[$ka]['d_username']=$this->get_username($va['d_uid']);
		}
		$this->assign('detail',$detail);
		$this->display();
	}
	
	//会议纪要-->详情 designed by:zhaoshihao 2017-10-17
	function meeting_minutes_detail_ajax(){
		$db_meeting_minutes=M('db_meeting_minutes');
		$db_meeting_minutes_detail=M('db_meeting_minutes_detail');
		$db_meeting_minutes_module=M('db_meeting_minutes_module');
		//
		$where['id']=$_REQUEST['mid'];
		$result=$db_meeting_minutes->where($where)->find();
		$where_h['id']=$result['hy_id'];
		$hy_id=$db_meeting_minutes->where($where_h)->find();
		//会议呈报
		$where_de['db_meeting_minutes_detail.mid']=$_REQUEST['mid'];
		$where_de['db_meeting_minutes_detail.uid']=$_REQUEST['uid'];
		$data=$db_meeting_minutes_detail->where($where_de)->find();
		if(!empty($hy_id)){
			$where_gl['mid']=$hy_id['id'];
			$where_gl['uid']=$data['uid'];
			$gl=$db_meeting_minutes_detail->where($where_gl)->find();
			$data['matter_gl']=$gl['matter'];
			$data['reply_gl']=$gl['reply'];
			$data['ready_things_gl']=$gl['ready_things'];
		}
		$data['username']=$this->get_username($va['uid']);
		$data['d_username']=$this->get_username($va['d_uid']);
		echo json_encode($data);die;
	}
	
	//审核流程管理 designed by:zhangsen 2017-12-12
	function audit_list(){
		parent::check_permission('LC');
		//查找
		if(!empty($_REQUEST['keyword'])){$keyword=$_REQUEST['keyword'];}
		$this->assign('keyword',$keyword);
		$db_audit_main=M('db_audit_main');
		if(!empty($keyword))
		{
			$map['db_project.project_num']=array('like','%'.$keyword.'%');
			$map['db_project.project_name']=array('like','%'.$keyword.'%');
			$map['_logic']='or';
			$where_p['_complex']=$map;
		}
		//审核状态
		if(!empty($_REQUEST['state'])){$state=$_REQUEST['state'];}else{$state=-10;}
		$this->assign('state',$state);
		//我的流程
		if(!empty($_REQUEST['type'])){$type=$_REQUEST['type'];}else{$type=1;}
		$this->assign('type',$type);
		//分类筛选
		if(!empty($_REQUEST['sh_type'])){$sh_type=$_REQUEST['sh_type'];}else{$sh_type=-10;}
		$this->assign('sh_type',$sh_type);
		//无项目经理
		$db_relationship=M('db_relationship');
		$where_r['leader_uid']=$this->login_id;
		$result_r=$db_relationship->where($where_r)->find();
		if($result_r){
			$person_uid=$result_r['person_uid'];
		}else{
			$person_uid='NULL';
		}
		$Model=M();
		if($state==1)
		{
			if($sh_type==5){
				$str='SELECT db_audit_main.* FROM `db_audit_main` LEFT JOIN db_universal_audit ON db_audit_main.status=db_universal_audit.audit_sort and db_universal_audit.type=5 and db_audit_main.audit_type=db_universal_audit.audit_type WHERE db_audit_main.type=5 and (find_in_set("'.$this->login_id.'",audit_uid) and db_audit_main.status>0) ORDER BY id desc';
			}elseif($sh_type==7){
				$str='SELECT db_audit_main.* FROM `db_audit_main` LEFT JOIN db_universal_audit ON db_audit_main.status=db_universal_audit.audit_sort and db_universal_audit.type=7 WHERE db_audit_main.type=7 and ((find_in_set("'.$this->login_id.'",audit_uid) and db_audit_main.status>1) or (db_audit_main.status=1 and add_uid in('.$person_uid.'))) ORDER BY id desc';
			}else{
				$str='SELECT db_audit_main.* FROM `db_audit_main` LEFT JOIN db_universal_audit ON db_audit_main.status=db_universal_audit.audit_sort and db_universal_audit.type=5 WHERE db_audit_main.type=5 and (find_in_set("'.$this->login_id.'",audit_uid) and db_audit_main.status>0) UNION ALL SELECT db_audit_main.* FROM `db_audit_main` LEFT JOIN db_universal_audit ON db_audit_main.status=db_universal_audit.audit_sort and db_universal_audit.type=7 WHERE db_audit_main.type=7 and ((find_in_set("'.$this->login_id.'",audit_uid) and db_audit_main.status>1) or (db_audit_main.status=1 and add_uid in('.$person_uid.'))) ORDER BY id desc';
			}
			$result=$Model->query($str);
		}
		elseif($state==2){
			if($sh_type==5){
				$where_p['_string']='(audit1_uid="'.$this->login_id.'" or audit2_uid="'.$this->login_id.'") and ((status=3) and (db_audit_main.type=5))';
			}
			elseif($sh_type==7){
				$where_p['_string']='(audit1_uid="'.$this->login_id.'" or audit2_uid="'.$this->login_id.'" or audit3_uid="'.$this->login_id.'" or audit4_uid="'.$this->login_id.'" or audit5_uid="'.$this->login_id.'") and ((status=6) and (db_audit_main.type=7))';
			}else{
				$where_p['_string']='(audit1_uid="'.$this->login_id.'" or audit2_uid="'.$this->login_id.'" or audit3_uid="'.$this->login_id.'" or audit4_uid="'.$this->login_id.'" or audit5_uid="'.$this->login_id.'") and (((status=3) and db_audit_main.type=5) or ((status=6) and (db_audit_main.type=7)))';
			}
			$result=$db_audit_main->where($where_p)->order('db_audit_main.id desc')->select();
		}else{
			if($sh_type==5){
				$str='SELECT db_audit_main.* FROM `db_audit_main` LEFT JOIN db_universal_audit ON db_audit_main.status=db_universal_audit.audit_sort and db_universal_audit.type=5 and db_audit_main.audit_type=db_universal_audit.audit_type WHERE db_audit_main.type=5 and ((find_in_set("'.$this->login_id.'",audit_uid) and db_audit_main.status>0) or (audit1_uid="'.$this->login_id.'" or audit2_uid="'.$this->login_id.'")) ORDER BY id desc';
			}
			elseif($sh_type==7){
				$str='SELECT db_audit_main.* FROM `db_audit_main` LEFT JOIN db_universal_audit ON db_audit_main.status=db_universal_audit.audit_sort and db_universal_audit.type=7 WHERE db_audit_main.type=7 and ((((find_in_set("'.$this->login_id.'",audit_uid) and db_audit_main.status>1) or (db_audit_main.status=1 and add_uid in('.$person_uid.')))) or (audit1_uid="'.$this->login_id.'" or audit2_uid="'.$this->login_id.'" or audit3_uid="'.$this->login_id.'" or audit4_uid="'.$this->login_id.'" or audit5_uid="'.$this->login_id.'")) ORDER BY id desc';
			}else{
				$str='SELECT db_audit_main.* FROM `db_audit_main` LEFT JOIN db_universal_audit ON db_audit_main.status=db_universal_audit.audit_sort and db_universal_audit.type=5 and db_audit_main.audit_type=db_universal_audit.audit_type WHERE db_audit_main.type=5 and ( (find_in_set("'.$this->login_id.'",audit_uid) and db_audit_main.status>0) or (audit1_uid="'.$this->login_id.'" or audit2_uid="'.$this->login_id.'") ) UNION ALL SELECT db_audit_main.* FROM `db_audit_main` LEFT JOIN db_universal_audit ON db_audit_main.status=db_universal_audit.audit_sort and db_universal_audit.type=7 WHERE db_audit_main.type=7 and (((find_in_set("'.$this->login_id.'",audit_uid) and db_audit_main.status>1) or (db_audit_main.status=1 and add_uid in('.$person_uid.'))) or (audit1_uid="'.$this->login_id.'" or audit2_uid="'.$this->login_id.'" or audit3_uid="'.$this->login_id.'" or audit4_uid="'.$this->login_id.'" or audit5_uid="'.$this->login_id.'") ) ORDER BY id desc';	
			}
			$result=$Model->query($str);
		}
		if(get_permission('LC',1))
		{
			unset($where_p);
			if($state==1){
				if($sh_type==5){
					$where_p['_string']='((status=1 or status=2) and (db_audit_main.type=5))';
				}
				elseif($sh_type==7){
					$where_p['_string']='((status=1 or status=2 or status=3 or status=4 or status=5) and (db_audit_main.type=7))';
				}else{
					$where_p['_string']="((status=1 or status=2) and (db_audit_main.type=5)) or ((status=1 or status=2 or status=3 or status=4 or status=5) and (db_audit_main.type=7))";
				}
			}elseif($state==2){
				if($sh_type==5){
					$where_p['_string']='((status=3) and (db_audit_main.type=5))';
				}
				elseif($sh_type==7){
					$where_p['_string']='((status=6) and (db_audit_main.type=7))';
				}else{
					$where_p['_string']="((status=3) and (db_audit_main.type=5)) or ((status=6) and (db_audit_main.type=7))";
				}
			}else{
				$where_p['db_audit_main.status']=array('in','1,2,3,4,5,6');
				if($sh_type==5){
					$where_p['db_audit_main.type']=5;
				}
				elseif($sh_type==7){
					$where_p['db_audit_main.type']=7;
				}else{
					$where_p['db_audit_main.type']=array('in','5,7');
					$where_p['db_audit_main.status']=array('in','1,2,3,4,5,6');
				}
			}
			$result=$db_audit_main->where($where_p)->order('db_audit_main.id desc')->select();
		}
		foreach($result as $k=>$v)
		{
			if($v['type']==6){
				//类别表
				$db_library_main=M('db_library_main');
				$where_t['id']=$v['audit_id'];
				$detail_sk=$db_library_main->where($where_t)->find();
				if($detail_sk['type']==2){
					$result[$k]['classif']=4;
					$result[$k]['dtype']=2;
				}elseif($detail_sk['type']==1){
					$result[$k]['classif']=1;
					$result[$k]['dtype']=1;
				}
				$audit_user=$this->audit_type_next($v['type'],NULL,$v['status']);
				$result[$k]['audit_user']=$audit_user['audit_user'];
				$result[$k]['audit_uid']=$audit_user['audit_uid'];
				$result[$k]['add_user']=$this->get_username($v['add_uid']);
				if($v['status']==2){$result[$k]['status_name']='已完结';}else{$result[$k]['status_name']='进行中';}
			}elseif($v['type']==7){
				$db_relationship=M('db_relationship');
				$where_rs['_string']="find_in_set('".$v['add_uid']."',person_uid)";
				$result_rs=$db_relationship->where($where_rs)->find();
				if($v['status']==1){
					$result[$k]['audit_user']=$result_rs['leader_name'];
					$result[$k]['audit_uid']=$result_rs['leader_uid'];
					$result[$k]['add_user']=$this->get_username($v['add_uid']);
				}else{
					$audit_user=$this->audit_type_next($v['type'],$v['audit_type'],$v['status']);
					$result[$k]['audit_user']=$audit_user['audit_user'];
					$result[$k]['audit_uid']=$audit_user['audit_uid'];
					$result[$k]['add_user']=$this->get_username($v['add_uid']);
				}
				if($v['status']==6){$result[$k]['status_name']='已完结';}else{$result[$k]['status_name']='进行中';}
			}else{
				$audit_user=$this->audit_type_next($v['type'],$v['audit_type'],$v['status']);
				$result[$k]['audit_user']=$audit_user['audit_user'];
				$result[$k]['audit_uid']=$audit_user['audit_uid'];
				$result[$k]['add_user']=$this->get_username($v['add_uid']);
				if($v['status']==3){$result[$k]['status_name']='已完结';}else{$result[$k]['status_name']='进行中';}
			}
			if($type==1){
				$audit_arr=explode(',',$result[$k]['audit_uid']);
				if(!in_array($this->login_id,$audit_arr)){
					unset($result[$k]);
				}
			}elseif($type==2){
				if($result[$k]['audit1_uid']!=$this->login_id && $result[$k]['audit2_uid']!=$this->login_id && $result[$k]['audit3_uid']!=$this->login_id && $result[$k]['audit4_uid']!=$this->login_id && $result[$k]['audit5_uid']!=$this->login_id){
					unset($result[$k]);
				}
			}
		}
		//数组分页
		//import("ORG.Util.Page");
		$count=count($result);
		//$Page=new  \Think\Page($count,C('PAGE_LIST_ROWS'),$parms);
		//$result=array_slice($result, $Page->firstRow,$Page->listRows);
		$result=array_slice($result,0,6);
		//$show=$Page->show();
		$this->assign('result',$result);
		$this->assign('count',$count);
		//$this->assign('page',$show);
		$this->display();
	}
	
	//审核流程管理-->下拉数据 designed by:zhangsen 2017-12-12
	function audit_list_show(){
		parent::check_permission('LC');
		$start=$_REQUEST['start_size'];
		$end=$_REQUEST['start_page'];
		//查找
		if(!empty($_REQUEST['keyword'])){$keyword=$_REQUEST['keyword'];}
		$this->assign('keyword',$keyword);
		$db_audit_main=M('db_audit_main');
		if(!empty($keyword))
		{
			$map['db_project.project_num']=array('like','%'.$keyword.'%');
			$map['db_project.project_name']=array('like','%'.$keyword.'%');
			$map['_logic']='or';
			$where_p['_complex']=$map;
		}
		//审核状态
		if(!empty($_REQUEST['state'])){$state=$_REQUEST['state'];}else{$state=-10;}
		$this->assign('state',$state);
		//我的流程
		if(!empty($_REQUEST['type'])){$type=$_REQUEST['type'];}else{$type=-10;}
		$this->assign('type',$type);
		//分类筛选
		if(!empty($_REQUEST['sh_type'])){$sh_type=$_REQUEST['sh_type'];}else{$sh_type=-10;}
		$this->assign('sh_type',$sh_type);
		//无项目经理
		$db_relationship=M('db_relationship');
		$where_r['leader_uid']=$this->login_id;
		$result_r=$db_relationship->where($where_r)->find();
		if($result_r){
			$person_uid=$result_r['person_uid'];
		}else{
			$person_uid='NULL';
		}
		$Model=M();
		if($state==1)
		{
			if($sh_type==5){
				$str='SELECT db_audit_main.* FROM `db_audit_main` LEFT JOIN db_universal_audit ON db_audit_main.status=db_universal_audit.audit_sort and db_universal_audit.type=5 WHERE db_audit_main.type=5 and (find_in_set("'.$this->login_id.'",audit_uid) and db_audit_main.status>0) ORDER BY id desc';
			}elseif($sh_type==7){
				$str='SELECT db_audit_main.* FROM `db_audit_main` LEFT JOIN db_universal_audit ON db_audit_main.status=db_universal_audit.audit_sort and db_universal_audit.type=7 WHERE db_audit_main.type=7 and ((find_in_set("'.$this->login_id.'",audit_uid) and db_audit_main.status>1) or (db_audit_main.status=1 and add_uid in('.$person_uid.'))) ORDER BY id desc';
			}else{
				$str='SELECT db_audit_main.* FROM `db_audit_main` LEFT JOIN db_universal_audit ON db_audit_main.status=db_universal_audit.audit_sort and db_universal_audit.type=5 WHERE db_audit_main.type=5 and (find_in_set("'.$this->login_id.'",audit_uid) and db_audit_main.status>0) UNION ALL SELECT db_audit_main.* FROM `db_audit_main` LEFT JOIN db_universal_audit ON db_audit_main.status=db_universal_audit.audit_sort and db_universal_audit.type=7 WHERE db_audit_main.type=7 and ((find_in_set("'.$this->login_id.'",audit_uid) and db_audit_main.status>1) or (db_audit_main.status=1 and add_uid in('.$person_uid.'))) ORDER BY id desc';
			}
			$result=$Model->query($str);
		}
		elseif($state==2){
			if($sh_type==5){
				$where_p['_string']='(audit1_uid="'.$this->login_id.'" or audit2_uid="'.$this->login_id.'") and ((status=3) and (db_audit_main.type=5))';
			}
			elseif($sh_type==7){
				$where_p['_string']='(audit1_uid="'.$this->login_id.'" or audit2_uid="'.$this->login_id.'" or audit3_uid="'.$this->login_id.'" or audit4_uid="'.$this->login_id.'" or audit5_uid="'.$this->login_id.'") and ((status=6) and (db_audit_main.type=7))';
			}else{
				$where_p['_string']='(audit1_uid="'.$this->login_id.'" or audit2_uid="'.$this->login_id.'" or audit3_uid="'.$this->login_id.'" or audit4_uid="'.$this->login_id.'" or audit5_uid="'.$this->login_id.'") and (((status=3) and db_audit_main.type=5) or ((status=6) and (db_audit_main.type=7)))';
			}
			$result=$db_audit_main->where($where_p)->order('db_audit_main.id desc')->select();
		}else{
			if($sh_type==5){
				$str='SELECT db_audit_main.* FROM `db_audit_main` LEFT JOIN db_universal_audit ON db_audit_main.status=db_universal_audit.audit_sort and db_universal_audit.type=5 WHERE db_audit_main.type=5 and (find_in_set("'.$this->login_id.'",audit_uid) and db_audit_main.status>0) or (audit1_uid="'.$this->login_id.'" or audit2_uid="'.$this->login_id.'") ORDER BY id desc';
			}
			elseif($sh_type==7){
				$str='SELECT db_audit_main.* FROM `db_audit_main` LEFT JOIN db_universal_audit ON db_audit_main.status=db_universal_audit.audit_sort and db_universal_audit.type=7 WHERE db_audit_main.type=7 and (((find_in_set("'.$this->login_id.'",audit_uid) and db_audit_main.status>1) or (db_audit_main.status=1 and add_uid in('.$person_uid.')))) or (audit1_uid="'.$this->login_id.'" or audit2_uid="'.$this->login_id.'" or audit3_uid="'.$this->login_id.'" or audit4_uid="'.$this->login_id.'" or audit5_uid="'.$this->login_id.'") ORDER BY id desc';
			}else{
				$str='SELECT db_audit_main.* FROM `db_audit_main` LEFT JOIN db_universal_audit ON db_audit_main.status=db_universal_audit.audit_sort and db_universal_audit.type=5 WHERE db_audit_main.type=5 and ( (find_in_set("'.$this->login_id.'",audit_uid) and db_audit_main.status>0) or (audit1_uid="'.$this->login_id.'" or audit2_uid="'.$this->login_id.'") ) UNION ALL SELECT db_audit_main.* FROM `db_audit_main` LEFT JOIN db_universal_audit ON db_audit_main.status=db_universal_audit.audit_sort and db_universal_audit.type=7 WHERE db_audit_main.type=7 and (((find_in_set("'.$this->login_id.'",audit_uid) and db_audit_main.status>1) or (db_audit_main.status=1 and add_uid in('.$person_uid.'))) or (audit1_uid="'.$this->login_id.'" or audit2_uid="'.$this->login_id.'" or audit3_uid="'.$this->login_id.'" or audit4_uid="'.$this->login_id.'" or audit5_uid="'.$this->login_id.'") ) ORDER BY id desc';	
			}
			$result=$Model->query($str);
		}
		if(get_permission('LC',1))
		{
			unset($where_p);
			if($state==1){
				if($sh_type==5){
					$where_p['_string']='((status=1 or status=2) and (db_audit_main.type=5))';
				}
				elseif($sh_type==7){
					$where_p['_string']='((status=1 or status=2 or status=3 or status=4 or status=5) and (db_audit_main.type=7))';
				}else{
					$where_p['_string']="((status=1 or status=2) and (db_audit_main.type=5)) or ((status=1 or status=2 or status=3 or status=4 or status=5) and (db_audit_main.type=7))";
				}
			}elseif($state==2){
				if($sh_type==5){
					$where_p['_string']='((status=3) and (db_audit_main.type=5))';
				}
				elseif($sh_type==7){
					$where_p['_string']='((status=6) and (db_audit_main.type=7))';
				}else{
					$where_p['_string']="((status=3) and (db_audit_main.type=5)) or ((status=6) and (db_audit_main.type=7))";
				}
			}else{
				$where_p['db_audit_main.status']=array('in','1,2,3,4,5,6');
				if($sh_type==5){
					$where_p['db_audit_main.type']=5;
				}
				elseif($sh_type==7){
					$where_p['db_audit_main.type']=7;
				}else{
					$where_p['db_audit_main.type']=array('in','5,7');
					$where_p['db_audit_main.status']=array('in','1,2,3,4,5,6');
				}
			}
			$result=$db_audit_main->where($where_p)->order('db_audit_main.id desc')->select();
		}
		foreach($result as $k=>$v)
		{
			if($v['type']==6){
				//类别表
				$db_library_main=M('db_library_main');
				$where_t['id']=$v['audit_id'];
				$detail_sk=$db_library_main->where($where_t)->find();
				if($detail_sk['type']==2){
					$result[$k]['classif']=4;
					$result[$k]['dtype']=2;
				}elseif($detail_sk['type']==1){
					$result[$k]['classif']=1;
					$result[$k]['dtype']=1;
				}
				$audit_user=$this->audit_type_next($v['type'],NULL,$v['status']);
				$result[$k]['audit_user']=$audit_user['audit_user'];
				$result[$k]['audit_uid']=$audit_user['audit_uid'];
				$result[$k]['add_user']=$this->get_username($v['add_uid']);
				if($v['status']==2){$result[$k]['status_name']='已完结';}else{$result[$k]['status_name']='进行中';}
			}elseif($v['type']==7){
				$db_relationship=M('db_relationship');
				$where_rs['_string']="find_in_set('".$v['add_uid']."',person_uid)";
				$result_rs=$db_relationship->where($where_rs)->find();
				if($v['status']==1){
					$result[$k]['audit_user']=$result_rs['leader_name'];
					$result[$k]['audit_uid']=$result_rs['leader_uid'];
					$result[$k]['add_user']=$this->get_username($v['add_uid']);
				}else{
					$audit_user=$this->audit_type_next($v['type'],$v['audit_type'],$v['status']);
					$result[$k]['audit_user']=$audit_user['audit_user'];
					$result[$k]['audit_uid']=$audit_user['audit_uid'];
					$result[$k]['add_user']=$this->get_username($v['add_uid']);
				}
				if($v['status']==6){$result[$k]['status_name']='已完结';}else{$result[$k]['status_name']='进行中';}
			}else{
				$audit_user=$this->audit_type_next($v['type'],$v['audit_type'],$v['status']);
				$result[$k]['audit_user']=$audit_user['audit_user'];
				$result[$k]['audit_uid']=$audit_user['audit_uid'];
				$result[$k]['add_user']=$this->get_username($v['add_uid']);
				if($v['status']==3){$result[$k]['status_name']='已完结';}else{$result[$k]['status_name']='进行中';}
			}
			if($type==1){
				$audit_arr=explode(',',$result[$k]['audit_uid']);
				if(!in_array($this->login_id,$audit_arr)){
					unset($result[$k]);
				}
			}elseif($type==2){
				if($result[$k]['audit1_uid']!=$this->login_id && $result[$k]['audit2_uid']!=$this->login_id && $result[$k]['audit3_uid']!=$this->login_id && $result[$k]['audit4_uid']!=$this->login_id && $result[$k]['audit5_uid']!=$this->login_id){
					unset($result[$k]);
				}
			}
		}
		$data=array_slice($result,$start,$end);
		echo json_encode($data);die;
	}
	
	//审核流程管理-->操作 designed by:zhangsen 2017-12-12
	function audit_list_ajax(){
		$db_audit_main=M('db_audit_main');
		$status=$_REQUEST['status'];
		$up_where['id']=$_REQUEST['mid'];
		$find_result=$db_audit_main->where($up_where)->find();
		$user_find=$this->get_user($find_result['add_uid']);
		$find_result['add_user']=$user_find['username'];
		$project=$this->get_project($find_result['pid']);
		if($_REQUEST['type']){$type=$_REQUEST['type'];}else{$type=3;}
		if(!empty($_REQUEST['uuid'])){
			$sta=$this->audit_type_next_person($type,$find_result['audit_type'],$status,'egt');
			if($find_result['flow_status']==-1){
				if($find_result['status']==$find_result['arrive_status']){
					$status=$find_result['dh_status'];
					$sta=$this->audit_type_next_person($type,$find_result['audit_type'],$status,'egt');
				}
			}
		}elseif(empty($_REQUEST['uuid'])){
			if($type==7){
				$relationship=$this->user_list_ajax_relationship(1,$find_result['add_uid']);
				if(($relationship['audit_uid']==$this->login_id) and ($find_result['status']==2)){
					$status=1;
					$sta['audit_sort']=1;
				}else{
					if($status!=-1){
						$sta=$this->audit_type_next_person($type,$find_result['audit_type'],$status,'lt');
						$status=$sta['audit_sort'];
					}
				}
			}else{
				if($status!=-1){
					$sta=$this->audit_type_next_person($type,$find_result['audit_type'],$status,'lt');
					$status=$sta['audit_sort'];
				}
			}
		}
		switch($status){
			case -1:
				if(!empty($_REQUEST['flow_status'])){
					if($_REQUEST['flow_status']==-1){
						$up_where=$this->audit_status_judge($_REQUEST['arrive_status']);
					}else{
						$up_where=$this->audit_status_judge_all($_REQUEST['arrive_status'],$_REQUEST['dh_status']);
					}
					$up_where['status']=$_REQUEST['arrive_status'];
					$up_where['id']=$_REQUEST['mid'];
				}else{
					$up_where['status']=-1;
					$up_where['post_uid']=NULL;$up_where['post_date']=NULL;
					$up_where['audit1_uid']=NULL;$up_where['audit1_date']=NULL;$up_where['audit1_message']=NULL;
					$up_where['audit2_uid']=NULL;$up_where['audit2_date']=NULL;$up_where['audit2_message']=NULL;
					$up_where['audit3_uid']=NULL;$up_where['audit3_date']=NULL;$up_where['audit3_message']=NULL;
					$up_where['audit4_uid']=NULL;$up_where['audit4_date']=NULL;$up_where['audit4_message']=NULL;
					$up_where['audit5_uid']=NULL;$up_where['audit5_date']=NULL;$up_where['audit5_message']=NULL;
				}
				if(!empty($_REQUEST['dh_message']))
				{
					$up_where['dh_uid']=$this->login_id;
					$up_where['dh_date']=date('Y-m-d H:i:s');
					$up_where['dh_message']=$_REQUEST['dh_message'];
					$up_where['dh_status']=$_REQUEST['dh_status'];
					$up_where['arrive_status']=$_REQUEST['arrive_status'];
					$up_where['flow_status']=$_REQUEST['flow_status'];
					$up_where['submit_info']=NULL;
				}else{
					if($find_result['status']!=1){
						unset($up_where);
					}
				}
				break;
			case 1:
				$up_where['audit1_uid']=NULL;$up_where['audit1_date']=NULL;$up_where['audit1_message']=NULL;
				$up_where['audit2_uid']=NULL;$up_where['audit2_date']=NULL;$up_where['audit2_message']=NULL;
				$up_where['audit3_uid']=NULL;$up_where['audit3_date']=NULL;$up_where['audit3_message']=NULL;
				$up_where['audit4_uid']=NULL;$up_where['audit4_date']=NULL;$up_where['audit4_message']=NULL;
				$up_where['audit5_uid']=NULL;$up_where['audit5_date']=NULL;$up_where['audit5_message']=NULL;
				if(!empty($_REQUEST['uuid'])){
					if($find_result['status']!=-1){
						unset($up_where);
					}else{
						$up_where['flow_status']=1;
						$up_where['status']=1;
						$up_where['post_uid']=$this->login_id;
						$up_where['post_date']=date('Y-m-d H:i:s');
						//发送提醒
						if($type==7){
							$relationship=$this->user_list_ajax_relationship(1,$find_result['add_uid']);
							$user=$this->get_user($relationship['audit_uid']);
							if($user['openid']){
								$this->send_audit_notice($user['openid'],'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxa9104bb1d0267056&redirect_uri=http://ko.joyuti.com/dms_erp/index.php?s=Mobile/Index/person_demand_detail/id/'.$find_result['audit_id'].'/audit/sh&response_type=code&scope=snsapi_base&state=1#wechat_redirect','您有新的审核流程，请及时处理。','人员需求','申请单号【'.$find_result['order_number'].'】',$find_result['add_user'],substr($find_result['add_date'],0,10),NULL);
							}
						}
					}
				}else{
					$up_where['status']=1;
					if($sta['audit_sort']!=$status){
						unset($up_where);
					}
				}
				break;
			case 2:
				if($type==6){
					if($find_result['status']!=1){
						unset($up_where);
					}else{
						$up_where['status']=$status;
						$up_where['audit1_uid']=$this->login_id;
						$up_where['audit1_date']=date('Y-m-d H:i:s');
					}
				}else{
					$up_where['audit2_uid']=NULL;$up_where['audit2_date']=NULL;$up_where['audit2_message']=NULL;
					$up_where['audit3_uid']=NULL;$up_where['audit3_date']=NULL;$up_where['audit3_message']=NULL;
					$up_where['audit4_uid']=NULL;$up_where['audit4_date']=NULL;$up_where['audit4_message']=NULL;
					$up_where['audit5_uid']=NULL;$up_where['audit5_date']=NULL;$up_where['audit5_message']=NULL;
					if(!empty($_REQUEST['uuid'])){
						if($find_result['flow_status']==-1 and $find_result['status']==$find_result['arrive_status']){
							$up_where['status']=$status;
							$up_where['flow_status']=1;
							if($find_result['status']!=$find_result['arrive_status']){
								unset($up_where);
							}else{
								if($find_result['arrive_status']==-1){
									$up_where['post_uid']=$this->login_id;
									$up_where['post_date']=date('Y-m-d H:i:s');
								}else{
									$up_where['audit'.$find_result['arrive_status'].'_uid']=$this->login_id;
									$up_where['audit'.$find_result['arrive_status'].'_date']=date('Y-m-d H:i:s');
									$up_where['audit'.$find_result['arrive_status'].'_message']=$_REQUEST['audit_message'];
									$up_where['submit_info']=$_REQUEST['audit_message'];
								}
							}
						}else{
							if($find_result['status']!=1){
								unset($up_where);
							}else{
								$up_where['status']=$sta['audit_sort'];
								$up_where['audit1_uid']=$this->login_id;
								$up_where['audit1_date']=date('Y-m-d H:i:s');
								$up_where['audit1_message']=$_REQUEST['audit_message'];
							}
						}
						if(!empty($up_where)){
							if($type==7){
								$audit_arr=explode(',',$sta['audit_uid']);
								foreach($audit_arr as $key=>$value){
									$user=$this->get_user($value);
									if($user['openid']){
										$this->send_audit_notice($user['openid'],'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxa9104bb1d0267056&redirect_uri=http://ko.joyuti.com/dms_erp/index.php?s=Mobile/Index/person_demand_detail/id/'.$find_result['audit_id'].'/audit/sh&response_type=code&scope=snsapi_base&state=1#wechat_redirect','您有新的审核流程，请及时处理。','人员需求','申请单号【'.$find_result['order_number'].'】',$find_result['add_user'],substr($find_result['add_date'],0,10),NULL);
									}
								}
							}elseif($type==5){
								$audit_arr=explode(',',$sta['audit_uid']);
								foreach($audit_arr as $key=>$value){
									$user=$this->get_user($value);
									if($user['openid']){
										$this->send_audit_notice($user['openid'],'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxa9104bb1d0267056&redirect_uri=http://ko.joyuti.com/dms_erp/index.php?s=Mobile/Project/task_detail/id/'.$find_result['audit_id'].'/audit/sh&response_type=code&scope=snsapi_base&state=1#wechat_redirect','您有新的审核流程，请及时处理。','任务管理','申请单号【'.$find_result['order_number'].'】',$find_result['add_user'],substr($find_result['add_date'],0,10),NULL);
									}
								}
							}
						}
					}else{
						$up_where['status']=$status;
						if($find_result['flow_status']==-1){
							if($find_result['dh_status']!=$status){
								unset($up_where);
							}
						}else{
							if($sta['audit_sort']!=$status){
								unset($up_where);
							}
						}
					}
				}
				break;
			case 3:
				$up_where['audit3_uid']=NULL;$up_where['audit3_date']=NULL;$up_where['audit3_message']=NULL;
				$up_where['audit4_uid']=NULL;$up_where['audit4_date']=NULL;$up_where['audit4_message']=NULL;
				$up_where['audit5_uid']=NULL;$up_where['audit5_date']=NULL;$up_where['audit5_message']=NULL;
				if(!empty($_REQUEST['uuid'])){
					if($find_result['flow_status']==-1 and $find_result['status']==$find_result['arrive_status']){
						$up_where['flow_status']=1;
						$up_where['status']=$status;
						if($find_result['status']!=$find_result['arrive_status']){
							unset($up_where);
						}else{
							if($find_result['arrive_status']==-1){
								$up_where['post_uid']=$this->login_id;
								$up_where['post_date']=date('Y-m-d H:i:s');
							}else{
								$up_where['audit'.$find_result['arrive_status'].'_uid']=$this->login_id;
								$up_where['audit'.$find_result['arrive_status'].'_date']=date('Y-m-d H:i:s');
								$up_where['audit'.$find_result['arrive_status'].'_message']=$_REQUEST['audit_message'];
								$up_where['submit_info']=$_REQUEST['audit_message'];
							}
						}
					}else{
						if($find_result['status']!=2){
							unset($up_where);
						}else{
							$up_where['status']=$status;
							$up_where['audit2_uid']=$this->login_id;
							$up_where['audit2_date']=date('Y-m-d H:i:s');
							$up_where['audit2_message']=$_REQUEST['audit_message'];
						}
					}
					if(!empty($up_where)){
						if($type==7){
							$audit_arr=explode(',',$sta['audit_uid']);
							foreach($audit_arr as $key=>$value){
								$user=$this->get_user($value);
								if($user['openid']){
									$this->send_audit_notice($user['openid'],'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxa9104bb1d0267056&redirect_uri=http://ko.joyuti.com/dms_erp/index.php?s=Mobile/Index/person_demand_detail/id/'.$find_result['audit_id'].'/audit/sh&response_type=code&scope=snsapi_base&state=1#wechat_redirect','您有新的审核流程，请及时处理。','人员需求','申请单号【'.$find_result['order_number'].'】',$find_result['add_user'],substr($find_result['add_date'],0,10),NULL);
								}
							}
						}
					}
				}else{
					$up_where['status']=$status;
					if($find_result['flow_status']==-1){
						if($find_result['dh_status']!=$status){
							unset($up_where);
						}
					}else{
						if($sta['audit_sort']!=$status){
							unset($up_where);
						}
					}
				}
				
				break;
			case 4:
				$up_where['audit4_uid']=NULL;$up_where['audit4_date']=NULL;$up_where['audit4_message']=NULL;
				$up_where['audit5_uid']=NULL;$up_where['audit5_date']=NULL;$up_where['audit5_message']=NULL;
				if(!empty($_REQUEST['uuid'])){
					if($find_result['flow_status']==-1 and $find_result['status']==$find_result['arrive_status']){
						$up_where['flow_status']=1;
						$up_where['status']=$status;
						if($find_result['status']!=$find_result['arrive_status']){
							unset($up_where);
						}else{
							if($find_result['arrive_status']==-1){
								$up_where['post_uid']=$this->login_id;
								$up_where['post_date']=date('Y-m-d H:i:s');
							}else{
								$up_where['audit'.$find_result['arrive_status'].'_uid']=$this->login_id;
								$up_where['audit'.$find_result['arrive_status'].'_date']=date('Y-m-d H:i:s');
								$up_where['audit'.$find_result['arrive_status'].'_message']=$_REQUEST['audit_message'];
								$up_where['submit_info']=$_REQUEST['audit_message'];
							}
						}
					}else{
						if($find_result['status']!=3){
							unset($up_where);
						}else{
							$up_where['status']=$status;
							$up_where['audit3_uid']=$this->login_id;
							$up_where['audit3_date']=date('Y-m-d H:i:s');
							$up_where['audit3_message']=$_REQUEST['audit_message'];
						}
					}
					if(!empty($up_where)){
						if($type==7){
							$audit_arr=explode(',',$sta['audit_uid']);
							foreach($audit_arr as $key=>$value){
								$user=$this->get_user($value);
								if($user['openid']){
									$this->send_audit_notice($user['openid'],'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxa9104bb1d0267056&redirect_uri=http://ko.joyuti.com/dms_erp/index.php?s=Mobile/Index/person_demand_detail/id/'.$find_result['audit_id'].'/audit/sh&response_type=code&scope=snsapi_base&state=1#wechat_redirect','您有新的审核流程，请及时处理。','人员需求','申请单号【'.$find_result['order_number'].'】',$find_result['add_user'],substr($find_result['add_date'],0,10),NULL);
								}
							}
						}
					}
				}else{
					$up_where['status']=$status;
					if($find_result['flow_status']==-1){
						if($find_result['dh_status']!=$status){
							unset($up_where);
						}
					}else{
						if($sta['audit_sort']!=$status){
							unset($up_where);
						}
					}
				}
				break;
			case 5:
				$up_where['audit5_uid']=NULL;$up_where['audit5_date']=NULL;$up_where['audit5_message']=NULL;
				if(!empty($_REQUEST['uuid'])){
					if($find_result['flow_status']==-1 and $find_result['status']==$find_result['arrive_status']){
						$up_where['flow_status']=1;
						$up_where['status']=$status;
						if($find_result['status']!=$find_result['arrive_status']){
							unset($up_where);
						}else{
							if($find_result['arrive_status']==-1){
								$up_where['post_uid']=$this->login_id;
								$up_where['post_date']=date('Y-m-d H:i:s');
							}else{
								$up_where['audit'.$find_result['arrive_status'].'_uid']=$this->login_id;
								$up_where['audit'.$find_result['arrive_status'].'_date']=date('Y-m-d H:i:s');
								$up_where['audit'.$find_result['arrive_status'].'_message']=$_REQUEST['audit_message'];
								$up_where['submit_info']=$_REQUEST['audit_message'];
							}
						}
					}else{
						if($find_result['status']!=4){
							unset($up_where);
						}else{
							$up_where['status']=$status;
							$up_where['audit4_uid']=$this->login_id;
							$up_where['audit4_date']=date('Y-m-d H:i:s');
							$up_where['audit4_message']=$_REQUEST['audit_message'];
						}
					}
					if(!empty($up_where)){
						if($type==7){
							$audit_arr=explode(',',$sta['audit_uid']);
							foreach($audit_arr as $key=>$value){
								$user=$this->get_user($value);
								if($user['openid']){
									$this->send_audit_notice($user['openid'],'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxa9104bb1d0267056&redirect_uri=http://ko.joyuti.com/dms_erp/index.php?s=Mobile/Index/person_demand_detail/id/'.$find_result['audit_id'].'/audit/sh&response_type=code&scope=snsapi_base&state=1#wechat_redirect','您有新的审核流程，请及时处理。','人员需求','申请单号【'.$find_result['order_number'].'】',$find_result['add_user'],substr($find_result['add_date'],0,10),NULL);
								}
							}
						}
					}
				}else{
					$up_where['status']=$status;
					if($find_result['flow_status']==-1){
						if($find_result['dh_status']!=$status){
							unset($up_where);
						}
					}else{
						if($sta['audit_sort']!=$status){
							unset($up_where);
						}
					}
				}
				break;
			case 6:
				if($find_result['status']!=5){
					unset($up_where);
				}else{
					$up_where['status']=$status;
					$up_where['audit5_uid']=$this->login_id;
					$up_where['audit5_date']=date('Y-m-d H:i:s');
					$up_where['audit5_message']=$_REQUEST['audit_message'];
				}
				break;
		}
		if($_REQUEST['submit_info']){$up_where['submit_info']=$_REQUEST['submit_info'];}
		$data['status']=$db_audit_main->save($up_where);
		echo json_encode($data);die;
	}
	
	//人员需求管理-->详情 designed by:zhangsen 2018-03-08
	function person_demand_detail(){
		$db_person_demand=M('db_person_demand');
		$where['db_person_demand.id']=$_REQUEST['id'];
		$where['db_audit_main.type']=7;
		$result=$db_person_demand->field('db_person_demand.*,db_audit_main.*,db_person_demand.id as tid')->join('db_audit_main on db_person_demand.id=db_audit_main.audit_id')->where($where)->find();
		$result['add_user']=$this->get_username($result['add_uid']);
		$result['report_user']=$this->get_username($result['report_uid']);
		$department=$this->get_oa_dep_info($result['department']);
		$result['department_name']=$department['HPS_DEPT_FULLDESCR'];
		$db_user=M('db_user');
		$where_p['position_id']=$result['position'];
		$result_user=$db_user->where($where_p)->find();
		$result['position_user']=$result['position_new']?$result['position_new']:$result_user['position_descr'];
		$result['dh_user']=$this->get_username($result['dh_uid']);
		$user=$this->get_user($result['add_uid']);
		$result['sq_position_user']=$user['position_descr'];
		$department=$this->get_oa_dep_info($user['department_id']);
		$result['sq_department_name']=$department['HPS_DEPT_FULLDESCR'];
		//审核人员
		$audit_arr=$this->audit_user(7,$result['audit_type']);
		foreach($audit_arr as $kk=>$vv){
			if($result['status']>$vv['audit_sort']){
				switch($vv['audit_name']){
					case '人力资源审批':
						$audit_arr[$kk]['audit_user']=$this->get_username($result['audit2_uid']);
						$audit_arr[$kk]['audit_date']=$result['audit2_date'];
						$audit_arr[$kk]['audit_comments']=$result['audit2_message'];
					break;
					case 'CHO审批':
						$audit_arr[$kk]['audit_user']=$this->get_username($result['audit3_uid']);
						$audit_arr[$kk]['audit_date']=$result['audit3_date'];
						$audit_arr[$kk]['audit_comments']=$result['audit3_message'];
					break;
					case '公司领导审批':
						$audit_arr[$kk]['audit_user']=$this->get_username($result['audit4_uid']);
						$audit_arr[$kk]['audit_date']=$result['audit4_date'];
						$audit_arr[$kk]['audit_comments']=$result['audit4_message'];
					break;
					case '人力资源部存档':
						$audit_arr[$kk]['audit_user']=$this->get_username($result['audit5_uid']);
						$audit_arr[$kk]['audit_date']=$result['audit5_date'];
						$audit_arr[$kk]['audit_comments']=$result['audit5_message'];
					break;
				}
			}
			if(empty($vv['audit_uid']) and empty($audit_arr[$kk]['audit_user'])){unset($audit_arr[$kk]);}
		}
		//判断审核人是否离职
		$relationship=$this->user_list_ajax_relationship(1,$result['add_uid']);
		if($relationship['audit_uid']){
			//判断审核人是否离职
			$judge_user1_user=$this->get_user($relationship['audit_uid']);
			if($judge_user1_user['status']!=1)
			{
				$relationship['audit_user']=$relationship['audit_user'].'(离职)';
			}
		}else{
			$relationship['audit_user']='无审核人';
		}
		
		$array1=array("audit_name"=>"用人部门审批","audit_user"=>"".$relationship['audit_user']."","audit_date"=>"".$result['audit1_date']."","audit_comments"=>"".$result['audit1_message']."","audit_sort"=>"1");
		array_unshift($audit_arr,$array1);
		$array2=array("audit_name"=>"申请人","audit_user"=>"".$this->get_username($result['post_uid'])."","audit_date"=>"".$result['post_date']."","audit_sort"=>"-1");
		array_unshift($audit_arr,$array2);
		foreach($audit_arr as $k1=>$v1){
			if($result['arrive_status']==$v1['audit_sort']){
				$arrive_name=$v1['audit_name'];
				if($result['arrive_status']=='-1'){$arrive_info=$result['submit_info'];}else{$arrive_info=$v1['audit_comments'];}
				$arrive_date=$v1['audit_date'];
			}
			if($result['dh_status']==$v1['audit_sort']){
				$audit_arr[$k1]['arrive_name']=$arrive_name;
				$audit_arr[$k1]['dh_message']=$result['dh_message'];
				$audit_arr[$k1]['dh_date']=$result['dh_date'];
				$audit_arr[$k1]['arrive_info']=$arrive_info;
				$audit_arr[$k1]['arrive_date']=$arrive_date;
			}
		}
		$this->assign('audit_user',$audit_arr);
		foreach($audit_arr as $ka=>$va){
			if($result['status']<=$va['audit_sort']){
				unset($audit_arr[$ka]);
			}
		}
		$this->assign('audit_list',$audit_arr);
		$audit_sh=$this->audit_type_next_person(7,$result['audit_type'],$result['status'],'egt');
		$audit_qs=$this->audit_type_next_person(7,$result['audit_type'],$result['status'],'lt');
		if($result['status']==1){
			if($relationship['audit_uid']==$this->login_id){
				$shenhe=1;
			}
		}else{
			if($result['status']!=-1){
				if(in_array($this->login_id,explode(',',$audit_sh['audit_uid']))){$shenhe=1;}
			}
		}
		if($result['status']==2){
			if($relationship['audit_uid']==$this->login_id){
				$qishen=1;
			}
		}else{
			if(in_array($this->login_id,explode(',',$audit_qs['audit_uid']))){$qishen=1;}
		}
		$this->assign('shenhe',$shenhe);
		$this->assign('qishen',$qishen);
		$this->assign('result',$result);
		$this->assign('audit',$_REQUEST['audit']);
		$this->assign('type',$_REQUEST['type']);
		$this->display();
	}
}
?>